﻿@using DTcms.Common;
@{
    List<SelectListItem> parentList = ViewBag.selectListItems;
}
@model DTcms.Model.navigation
<form id="form1" class="layui-form" url="NavSave?action=@ViewBag.action&id=@ViewBag.id">
    @Html.AntiForgeryToken()
    <!--导航栏-->
    <div class="pageheader">
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li><a href="../settings/nav_list" class="back"><i class="fa fa-mail-reply-all"></i> 返回列表页</a></li>
                <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
                <li><a href="../settings/nav_list">导航列表</a> </li>
                <li><a href="javascript:;">编辑后台导航</a> </li>
            </ul>
        </div>
    </div>
    <!--/导航栏-->
    <!--内容-->
    <div class="layui-fluid">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title" id="floatHead">
                <li class="layui-this">基本信息</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">上级导航</label>
                        <div class="layui-input-block">
                            @if (Model.is_sys == 1)
                            {
                                @Html.DropDownList("parent_id", new SelectList(parentList, "Value", "Text", Model.parent_id.ToString()), new { disabled = "disabled" })
                            }
                            else
                            {
                                @Html.DropDownList("parent_id", new SelectList(parentList, "Value", "Text", Model.parent_id.ToString()))
                            }
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">排序数字</label>
                        <div class="layui-input-block">
                            @Html.TextBox("sort_id", Model.sort_id, new { @class = "input small", datatype = "n", sucmsg = " " })
                            <span class="Validform_checktip">*数字，越小越向前</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否隐藏</label>
                        <div class="layui-input-block">
                            @Html.CheckBox("is_lock", Model.is_lock == 0, new { title = "是" })
                            <span class="Validform_checktip">*隐藏后不显示在界面导航菜单中。</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">调用别名</label>
                        <div class="layui-input-block">
                            @Html.TextBox("name", Model.name, new { @class = "input normal", datatype = @"/^[a-zA-Z0-9\-\_]{2,50}$/", errormsg = "请填写正确的ID", sucmsg = " " })
                            <span class="Validform_checktip">权限控制名称，只允许字母、数字、下划线</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">导航标题</label>
                        <div class="layui-input-block">@Html.TextBox("title", Model.title, new { @class = "input normal", datatype = "*1-100", sucmsg = " " })<span class="Validform_checktip">*导航中文标题，100字符内</span></div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">副标题</label>
                        <div class="layui-input-block">
                            @Html.TextBox("sub_title", Model.sub_title, new { @class = "input normal", datatype = "*0-100", sucmsg = " " })
                            <span class="Validform_checktip">非必填，当导航拥有两个名称时使用</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">自定义图标</label>
                        <div class="layui-input-block">
                            @Html.TextBox("icon_url", Model.icon_url, new { @class = "input normal", maxlength = "255", style = "display:none" })
                            <a class="layui-btn layui-btn-primary icon-btn spec-btn"><i class="iconfont icon-pic"></i> 图标库</a>
                            <span style="font-size: 25px;display: inline-block;margin: -4px;width: 60px;line-height: 42px;text-align: center;cursor: pointer;vertical-align: top;height: 40px;">
                                <i id="font_icon" class="@Model.icon_url"></i>
                            </span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">链接地址</label>
                        <div class="layui-input-block">
                            @Html.TextBox("link_url", Model.link_url, new { @class = "input normal", maxlength = "255" })
                            <span class="Validform_checktip">当前管理目录，有子导航不用填</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备注说明</label>
                        <div class="layui-input-block">
                            @Html.TextArea("remark", Model.remark, new { @class = "input" })
                            <span class="Validform_checktip">非必填，可为空</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">权限资源</label>
                        <div class="layui-input-block">
                            @foreach (KeyValuePair<string, string> kv in Utils.ActionType())
                            {
                                <input id="cblActionType_@kv.Key" name="cblActionType_@kv.Key" title="@kv.Value" type="checkbox" value="true" @(Model.action_type.ToLower().IndexOf(kv.Key.ToLower()) >= 0?"checked":"") />
                            }
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--/内容-->
    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-wrap">
            <button class="layui-btn icon-btn" id="btnSubmit"><i class="layui-icon layui-icon-ok"></i>提交保存</button>
            <button class="layui-btn layui-btn-warm icon-btn" name="btnReturn" onclick="javascript:history.back(-1);"><i class="layui-icon layui-icon-return"></i>返回上一页</button>
        </div>
    </div>
    <!--/工具栏-->
</form>
@section Scripts{
    <script type="text/javascript">
        layui.use(['jqueryform', 'element', 'validform'], function () {
            //初始化表单验证
            $("#form1").initValidform('#btnSubmit', 1);

            if ("@ViewBag.action" == "@DTEnums.ActionEnum.Edit.ToString()") {
                $("#name").attr("readonly", "readonly").focus();
            }

            //创建自定义图标库
            $(".spec-btn").click(function () {
                showIconDialog();
            });
        });
        //初始化自定义图标库窗口
        function showIconDialog() {
            var d=layer.open({
                type: 2,
                area: ['800px', '520px'],
                title: "图标库",
                maxmin: true,
                content: '../settings/icon',
                btn: ['关闭'],
                success: function (layero, index) {
                    var body = layer.getChildFrame('body', index);
                    var iframeWin = window[layero.find('iframe')[0]['name']];
                    iframeWin.submitValue($("#icon_url"));
                }
            });
        }
    </script>
}